package com.javase.Homework;

import java.util.Random;
import java.util.Scanner;

public class Homework09 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Tom tom = new Tom();
        tom.aa();
    }
}

class Tom{
    int n1;
    int count;
    public void aa(){
        Scanner scanner = new Scanner(System.in);
        Random random = new Random();
        for (int i = 0 ; i < 10 ;i++){
            System.out.println("请输入0（石头）1（剪刀）2（布）");
            int n1 = scanner.nextInt();
            if (n1<3&&n1>=0) {
                this.n1 = random.nextInt(3);
                if (this.n1 == n1) {
                    System.out.println("打平了" + this.n1 + " " + n1);
                } else if (this.n1 == 0 && n1 == 2) {
                    System.out.println("tom胜，记一分" + this.n1 + " " + n1);
                    count++;
                } else if (this.n1 < n1) {
                    System.out.println("电脑胜，不计分" + this.n1 + " " + n1);
                } else {
                    System.out.println("tom胜，记一分" + this.n1 + " " + n1);
                    count++;
                }
            }else {
                System.out.println("请输入0-2！");
            }
        }
        System.out.println("tom赢得次数为"+count+"次");
    }
}